const koa = require("koa")

const {
  initRouter,
  initController,
  initServce,
  loadConfig,
  initSchedule
} = require("./zxc-loader")

class Zxc {
  constructor(conf) {
    this.$app = new koa(conf)
    // 加载配置项
    loadConfig(this)
    initSchedule()
    this.$service = initServce()
    this.$ctrl = initController(this)
    this.$router = initRouter(this)
    this.$app.use(this.$router.routes())
  }
  start(port) {
    this.$app.listen(port, () => {
      console.log("服务器启动" + port)
    })
  }
}
module.exports = Zxc
